//
//  DnpActionSheet.m
//  dnp_plugin
//
//

#import "DnpActionSheet.h"

@implementation DnpActionSheet

+ (void)show:(UIViewController *)controller completion:(void (^)(BOOL))completion {
    
    NSString *selectBlumText = @"Select from the album";
    NSString *takePhotoText = @"Take Photo";
    NSString *closeText = @"Cancel";
    
    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil
                                                                                 message:nil
                                                                          preferredStyle:UIAlertControllerStyleActionSheet];

    UIAlertAction *selectAlbum = [UIAlertAction actionWithTitle:selectBlumText
                                                       style:UIAlertActionStyleDefault
                                                     handler:^(UIAlertAction * _Nonnull action) {
        if (completion) {
            completion(YES);
        }
    }];

    UIAlertAction *takePhoto = [UIAlertAction actionWithTitle:takePhotoText
                                                       style:UIAlertActionStyleDefault
                                                     handler:^(UIAlertAction * _Nonnull action) {
        if (completion) {
            completion(NO);
        }
    }];

    UIAlertAction *close = [UIAlertAction actionWithTitle:closeText
                                                      style:UIAlertActionStyleCancel
                                                    handler:nil];

    [alertVC addAction:selectAlbum];
    [alertVC addAction:takePhoto];
    [alertVC addAction:close];

    if (controller) {
        [controller presentViewController:alertVC animated:YES completion:nil];
    }
}

@end
